#ifndef _VN_SFML_SPRITE_MANAGER_H_
#define _VN_SFML_SPRITE_MANAGER_H_

#include <string>
#include <list>
#include <vector>
#include "..\Managers\SFMLFontManager.h"
#include "..\Managers\SFMLTextureManager.h"
#include "..\Graphics\SFMLSprite.h"
#include "..\Graphics\SFMLText.h"
#include "..\Engines\SFMLTileEngine.h"
#include "..\Graphics\SFMLRectangleShape.h"
#include "..\Generic\DataFilepath.h"

class SFMLSpriteManager
{
public:
	typedef std::vector<std::pair<sf::View, std::list<vn::SFMLDrawable*>>> SpriteView;

	SFMLSpriteManager(unsigned int);
	virtual ~SFMLSpriteManager(void);

	void drawSprites(sf::RenderWindow&);
	void drawSprites(sf::RenderTexture&);
	vn::Sprite* createSprite(unsigned int, const std::string&, float = 0.0f);
	vn::Text* createText(unsigned int p_view, const std::string& p_fontID, const std::string& p_string, float p_layer = 0.0f);
	vn::TileEngine* createTiles(unsigned int, const std::string&, float = 0.0f);
	vn::RectangleShape* createRectangleShape(unsigned int p_view, const vn::Vector2& size, float p_layer = 0.0f);

	void destroySprite(vn::SFMLSprite*);
	void destroyTileEngine(vn::SFMLTileEngine*);
	void destroyText(vn::SFMLText*);
	void destroyRectangleShape(vn::SFMLRectangleShape*);

	void setView(unsigned int p_view, sf::RenderWindow& p_renderWindow);
	void setView(unsigned int p_view, sf::RenderTexture& p_renderTexture);
	sf::View* getView(unsigned int);

	vn::SFMLTextureManager& getTextureManager() { return *m_textureManager; }

	void clearAllDrawables();
private:
	void setViews(unsigned int);
	inline void insertDrawable(vn::SFMLDrawable*, unsigned int);


	SpriteView m_sprites;
	vn::SFMLTextureManager* m_textureManager;
	SFMLFontManager* m_fontManager;

	DataFilepath m_dataFilepaths;
};

#endif // _VN_SFML_SPRITE_MANAGER_H_